package restPROC;

import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import utilClasses.ListaString;


import dao.daoKonekcija;
import dao.daoKorisnik;

@Path("/korisnik") 
public class Korisnik {
	@GET
	@Path("/dajTipove")
	@Produces({"application/xml"})
	public ListaString dajTipove()
	{
		ListaString rez=new ListaString();
		try {
			
			rez=daoKorisnik.dajTipoveKorisnika();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return rez;
	}
	
	@POST
	@Path("/registruj")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces("plain/text")
	public String registruj(@FormParam("ime") String ime,@FormParam("telefon") String telefon,@FormParam("tip") String tip,@FormParam("uname") String uname,@FormParam("pass") String pass)
	{
		try {
			
			daoKorisnik.RegistrujKorisnika(ime, telefon, tip, uname, pass);
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return "false";
		}
		return "true";
	}
}
